// pages/my/my.js
const app = getApp()
const util = require('../../utils/util.js');
const api = require('../../utils/api.js');
Page({

    /**
     * 页面的初始数据
     */
    data: {
        pageColor: app.pageColor.mainColor,
        myOrderStatus: [
            { OrderStatus: "../../icons/dd-01.png", text: "我的订单" },
            { OrderStatus: "../../icons/dd-02.png", text: "代付款" },
            { OrderStatus: "../../icons/dd-03.png", text: "代发货" },
            { OrderStatus: "../../icons/dd-04.png", text: "待收货" }
            // { OrderStatus: "../../icons/dd-05.png", text: "售后/退款" }
        ],
        mobile: "",
        redMoneyCon: true,
        myMsg: ''
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },
    onReady: function () {
        util.setNavigationBarTitle("我的");
    },
    // 获取个人信息
    getMsg: function () {
        var that = this;
        let url = api.userInfo();
        util.http(true, "GET", url, 'null', res => {
            that.setData({
                myMsg: res
            })
        })
    },
    // 获取手机号码
    getPhone: function () {
        var that = this;
        let url = api.shopInfo();
        util.http(false, "GET", url, 'null', res => {
            that.setData({
                mobile: res.service_number
            })
        })
    },
    changeHeadImg: function () {
        wx.navigateTo({
            url: '../upload/upload'
        })
    },
    unionSeller: function () {
        wx.switchTab({
            url: '../unionSeller/unionSeller'
        })
    },
    makePhone: function () {
        var that = this;
        var num = that.data.mobile;
        util.makePhone(num);
    },
    addressManage: function () {
        util.addMsg();
    },


    nav: function (e) {
        if (e.currentTarget.dataset.i != 4) {
            wx.navigateTo({
                url: '../order/order?id=' + e.currentTarget.dataset.i
            })
        }
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        this.getMsg();
        this.getPhone();
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})